package utstat;

public class SpawnManager {

	static int gameBalance = 0;
	static int teamBalance = 0;
	static int baseSpawnTime = 8;
	
	public static void setGameBalanceSpawnOffset(int spawnOffset) {
		System.out.println("gameplay offset set to "+spawnOffset);
		gameBalance = spawnOffset;
		 apply();
	}

public static void setTeamBalanceSpawnOffset(int spawnOffset) {
	System.out.println("team offset set to "+spawnOffset);
	gameBalance = 0;
	teamBalance = spawnOffset;
	if(teamBalance==10||teamBalance==-10) teamBalance=0; // it's only 10 when there's one player
	 apply();
	}

private static void apply() {
	double spawnOffset = (gameBalance+teamBalance)/2.0;
	int redOffset = (int)Math.ceil(spawnOffset);
	int blueOffset = -(int)Math.floor(spawnOffset);
	System.out.println("red spawn:"+(baseSpawnTime+redOffset)+" bluespawn:"+(baseSpawnTime+blueOffset));
	Rcon.setSpawnTimes(baseSpawnTime+redOffset, baseSpawnTime+blueOffset);
}

	public static void nextRound() {
		gameBalance = 0;
		teamBalance = 0;
		baseSpawnTime = 8;
	}
}
